<html><head><title>odefile (MATLAB Function Reference)</title>
<!-- $Revision: 1.21 $  $Date: 2000/09/14 20:55:13 $ -->

<!-- DOCNAME: MATLAB Function Reference -->
<!-- CHUNKNAME: odefile -->
<!-- CHAPNAME: odefile -->
<!-- HEADSTUFF -->
</head>
<body bgcolor=#ffffff>
<p>This reference page does no longer describe the odefile and the syntax of the 
  ODE solvers used in MATLAB, Version 5. MATLAB, because in the newer Version 
  6, the solver syntax does not use an ODE file anymore. We have created a new 
  odefile with functionality that can be used by the new solvers. The MATCONT 
  user doesn't need any information about this odefile because it is automatically 
  generated by MATCONT.</p>
<p>Example of system generated with MATCONT using its prototype odefile:</p>
<p>function out = catalytic(t, coordinates, flag, q1, q2, q3, q4, q5, q6, k)</p>
<p>%generates handles to jacobian, etc..<br>
  out{1} = @init;<br>
  out{2} = @fun_eval;<br>
  out{3} = @jacobian;<br>
  out{4} = @jacobianp;<br>
  out{5} = @hessians;<br>
  out{6} = @hessiansp;<br>
  out{7} = @der3;<br>
  out{8} = @[];<br>
  out{9} = @[];<br>
  out{10}= @q2q;</p>
<p>% --------------------------------------------------------------------------<br>
  function dydt = fun_eval(t,kmrgd,q1,q2,q3,q4,q5,q6,k)<br>
  dydt=[2*q1*(1-kmrgd(1)-kmrgd(2)-kmrgd(3))^2-2*q5*kmrgd(1)^2-q3*kmrgd(1)*kmrgd(2);<br>
  q2*(1-kmrgd(1)-kmrgd(2)-kmrgd(3))-q6*kmrgd(2)-q3*kmrgd(1)*kmrgd(2);<br>
  q4*(1-kmrgd(1)-kmrgd(2)-kmrgd(3))-k*q4*kmrgd(3);];</p>
<p>% --------------------------------------------------------------------------<br>
  function [tspan,y0,options] = init<br>
  handles = feval(catalytic);<br>
  y0=[0,0,0];<br>
  options = odeset('Jacobian',handles(3),'JacobianP',handles(4),'Hessians',handles(5),'HessiansP',handles(6));<br>
  tspan = [0 10];</p>
<p>% --------------------------------------------------------------------------<br>
  function jac = jacobian(t,kmrgd,q1,q2,q3,q4,q5,q6,k)<br>
  jac=[[-4*q1*(1-kmrgd(1)-kmrgd(2)-kmrgd(3))-4*q5*kmrgd(1)-q3*kmrgd(2),-4*q1*(1-kmrgd(1)-kmrgd(2)-kmrgd(3))-q3*kmrgd(1),-4*q1*(1-kmrgd(1)-kmrgd(2)-kmrgd(3))];[-q2-q3*kmrgd(2),-q2-q6-q3*kmrgd(1),-q2];[-q4,-q4,-q4-k*q4]];<br>
  % --------------------------------------------------------------------------<br>
  function jacp = jacobianp(t,kmrgd,q1,q2,q3,q4,q5,q6,k)<br>
  jacp=[[2*(1-kmrgd(1)-kmrgd(2)-kmrgd(3))^2,0,-kmrgd(1)*kmrgd(2),0,-2*kmrgd(1)^2,0,0];[0,1-kmrgd(1)-kmrgd(2)-kmrgd(3),-kmrgd(1)*kmrgd(2),0,0,-kmrgd(2),0];[0,0,0,1-kmrgd(1)-kmrgd(2)-kmrgd(3)-k*kmrgd(3),0,0,-q4*kmrgd(3)]];<br>
  % --------------------------------------------------------------------------<br>
  function hess = hessians(t,kmrgd,q1,q2,q3,q4,q5,q6,k)<br>
  hess1=[[4*q1-4*q5,4*q1-q3,4*q1];[0,-q3,0];[0,0,0]];<br>
  hess2=[[4*q1-q3,4*q1,4*q1];[-q3,0,0];[0,0,0]];<br>
  hess3=[[4*q1,4*q1,4*q1];[0,0,0];[0,0,0]];<br>
  hess(:,:,1) =hess1;<br>
  hess(:,:,2) =hess2;<br>
  hess(:,:,3) =hess3;<br>
  % --------------------------------------------------------------------------<br>
  function hessp = hessiansp(t,kmrgd,q1,q2,q3,q4,q5,q6,k)<br>
  hessp1=[[-4+4*kmrgd(1)+4*kmrgd(2)+4*kmrgd(3),-4+4*kmrgd(1)+4*kmrgd(2)+4*kmrgd(3),-4+4*kmrgd(1)+4*kmrgd(2)+4*kmrgd(3)];[0,0,0];[0,0,0]];<br>
  hessp2=[[0,0,0];[-1,-1,-1];[0,0,0]];<br>
  hessp3=[[-kmrgd(2),-kmrgd(1),0];[-kmrgd(2),-kmrgd(1),0];[0,0,0]];<br>
  hessp4=[[0,0,0];[0,0,0];[-1,-1,-1-k]];<br>
  hessp5=[[-4*kmrgd(1),0,0];[0,0,0];[0,0,0]];<br>
  hessp6=[[0,0,0];[0,-1,0];[0,0,0]];<br>
  hessp7=[[0,0,0];[0,0,0];[0,0,-q4]];<br>
  hessp(:,:,1) =hessp1;<br>
  hessp(:,:,2) =hessp2;<br>
  hessp(:,:,3) =hessp3;<br>
  hessp(:,:,4) =hessp4;<br>
  hessp(:,:,5) =hessp5;<br>
  hessp(:,:,6) =hessp6;<br>
  hessp(:,:,7) =hessp7;<br>
  %---------------------------------------------------------------------------<br>
  function tens3 = der3(t,kmrgd,q1,q2,q3,q4,q5,q6,k)<br>
  tens31=[[0,0,0];[0,0,0];[0,0,0]];<br>
  tens32=[[0,0,0];[0,0,0];[0,0,0]];<br>
  tens33=[[0,0,0];[0,0,0];[0,0,0]];<br>
  tens34=[[0,0,0];[0,0,0];[0,0,0]];<br>
  tens35=[[0,0,0];[0,0,0];[0,0,0]];<br>
  tens36=[[0,0,0];[0,0,0];[0,0,0]];<br>
  tens37=[[0,0,0];[0,0,0];[0,0,0]];<br>
  tens38=[[0,0,0];[0,0,0];[0,0,0]];<br>
  tens39=[[0,0,0];[0,0,0];[0,0,0]];<br>
  tens3(:,:,1,1) =tens31;<br>
  tens3(:,:,1,2) =tens32;<br>
  tens3(:,:,1,3) =tens33;<br>
  tens3(:,:,2,1) =tens34;<br>
  tens3(:,:,2,2) =tens35;<br>
  tens3(:,:,2,3) =tens36;<br>
  tens3(:,:,3,1) =tens37;<br>
  tens3(:,:,3,2) =tens38;<br>
  tens3(:,:,3,3) =tens39;<br>
  %---------------------------------------------------------------------------<br>
  function tens4 = der4(t,kmrgd,q1,q2,q3,q4,q5,q6,k)<br>
  %---------------------------------------------------------------------------<br>
  function tens5 = der5(t,kmrgd,q1,q2,q3,q4,q5,q6,k)</p>
<p>%----------------------------------------------------------------------------<br>
  function userfun1=q2q(t,kmrgd,q1,q2,q3,q4,q5,q6,k)<br>
  userfun1=q2-1;<br>
</p>
</body>
</html>